<template>
  <!--  这个是访问量的-->
  <div>
    <div ref="visitBar" class="bar" />
  </div>
</template>

<script>
import * as echarts from 'echarts'
import { mapState } from 'vuex'
export default {
  name: 'MyCharts',
  mounted() {
    console.log(' this.userFullYearAxis', this.userinfo.userFullYearAxis)
    const myChart = echarts.init(this.$refs.visitBar)
    myChart.setOption({
      title: {
        text: '访问量'
      },
      xAxis: {
        type: 'category',
        data: this.userinfo.userFullYearAxis
      },
      yAxis: {
        type: 'value'
      },
      series: [
        {
          data: this.userinfo.userFullYear,
          type: 'bar',
          showBackground: true,
          color: 'pink',
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)'
          }
        }
      ]
    })
  },
  computed: {
    ...mapState({
      userinfo: state => state.home.echartsinfo
    })
  }
}
</script>

<style scoped>
.bar{
  width: 100%;
  height: 300px;
}
.ranking{
  list-style: none;
}
.ranking .rankingItem span{
  margin-right: 20px;
  margin-top: 10px;
  font-size: 16px;
}
.ranking .rankingItem span:nth-child(1){
  display: inline-block;
  text-align: center;
  width: 20px;
  height: 20px;
  line-height: 1.2rem;
}
.ranking .rankingItem:nth-child(1) span:nth-child(1){
  background-color: black;
  border-radius: 50%;
  color: #f4f4f5;
}
.ranking .rankingItem:nth-child(2) span:nth-child(1){
  background-color: black;
  border-radius: 50%;
  color: #f4f4f5;
}
.ranking .rankingItem:nth-child(3) span:nth-child(1){
  background-color: black;
  border-radius: 50%;
  color: #f4f4f5;
}
.ranking .rankingItem:nth-child(1) span:nth-child(2){
  font-weight: bold;
}
.ranking .rankingItem:nth-child(2) span:nth-child(2){
  font-weight: bold;
}
.ranking .rankingItem:nth-child(3) span:nth-child(2){
  font-weight: bold;
}
</style>
